package com.ruoyi.common.enums;

public enum DataType {
    ITEM(1, "ITEM"),
    INVENTORY(2, "INVENTORY"),
    CANCELLATION(3, "CANCELLATION"),
    DELIVERY_DEFECT(4, "DELIVERY_DEFECT"),
    ITEM_PERFORMANCE(5, "ITEM_PERFORMANCE"),
    PROMO(6, "PROMO"),
    RETURN_OVERRIDES(7, "RETURN_OVERRIDES"),
    CPA(8, "CPA"),
    SHIPPING_CONFIGURATION(9, "SHIPPING_CONFIGURATION"),
    SHIPPING_PROGRAM(10, "SHIPPING_PROGRAM"),
    FITMENT_MISSING_ATTR(11, "FITMENT_MISSING_ATTR"),
    FITMENT_ACES_COVERAGE(12, "FITMENT_ACES_COVERAGE"),
    BUYBOX(13, "BUYBOX"),
    ASSORTMENT_RECOMMENDATIONS(14, "ASSORTMENT_RECOMMENDATIONS"),
    LAGTIME(15, "LAGTIME");

    private final Integer value;
    private final String name;

    // Constructor to assign values
    DataType(Integer value, String name) {
        this.value = value;
        this.name = name;
    }

    // Getter for value
    public Integer getValue() {
        return value;
    }

    // Getter for name
    public String getName() {
        return name;
    }

    // Optional: Method to get enum by integer value
    public static DataType fromValue(Integer value) {
        for (DataType dataType : DataType.values()) {
            if (dataType.getValue().equals(value)) {
                return dataType;
            }
        }
        throw new IllegalArgumentException("Unexpected value: " + value);
    }

    // Optional: Method to get enum by name (String)
    public static DataType fromName(String name) {
        for (DataType dataType : DataType.values()) {
            if (dataType.getName().equals(name)) {
                return dataType;
            }
        }
        throw new IllegalArgumentException("Unexpected name: " + name);
    }

    public static boolean isValidName(String name) {
        for (DataType dataType : DataType.values()) {
            if (dataType.getName().equals(name)) {
                return true;  // 如果找到了匹配的枚举，返回true
            }
        }
        return false;  // 如果没有匹配的枚举，返回false
    }
}
